<?php
      $filename = date("Y-m-d-H-i-s").".xls";
      header('Content-type: application/ms-excel');
      header('Content-Disposition: attachment; filename='.$filename);
?>
<html>
<head>
	<title>Report Excel </title>
	<style media="all" >
	table.data{
		border-collapse: collapse;
		width: 100%;
	}
	table.data tr td,table.data tr th{ font-size: 11px; font-family: Arial; padding: 5px;}
	table.data tr th{background-color: #f1f1f1;}
	h3,h4{padding: 0px; margin: 0px;}
	</style>
</head>
<body>
	<?php if(isset($client)){ ?>
	<div style="padding:4px; background-color:#f1f1f1; border:1px solid #ccc; margin-bottom:5px; font-size:12px;">
	<h3 style="font-size:18px; "><?php echo isset($client)?$client->cabang_name:'';?></h3>
	<?php if(isset($ex['data']) && count($ex['data']) > 0){ ?>
	<h4>Jumlah Data : <?php echo count($ex['data']);?> data</h4>
	<?php
		$jumlah = 0;
		foreach($ex['data'] as $m){
			//$premi =  ($m->detail_uang_ptg * $m->detail_periode_ptg * $m->detail_tarif_premi)/100;
			$premi =  $m->detail_uang_ptg;
			$jumlah += $premi;
		}
	?>
	<h4>Total Uang Pertanggungan : <?php echo myNum($jumlah);?></h4>
	<?php } ?>
	</div>
	<?php } ?>
	
	
	<table class="data" border="1">
		<tr>
			<th>No</th>  
	        <th>Nama</th>
	        <th>Alamat</th>
	        <th>Tgl Akad</th>
	        <th>Tgl Lahir</th>
	        <th>USIA</th>
	        <th>Periode Pertanggungan</th>
	        <th>Uang Pertanggungan</th>
	        <th>Tarif Premi (%)</th>    
	        <?php if($this->bav_type == 'agunan'){?>
	        	<th>Object Pertanggungan</th>
	        <?php } ?>  
	        <th>Premi</th>
		</tr>
	    <?php if(isset($ex['data']) && count($ex['data']) > 0){
				$no=1;
				foreach($ex['data'] as $r){
					$premi =  ($r->detail_uang_ptg * $r->detail_periode_ptg * $r->detail_tarif_premi)/100;
			?>
	     		<tr>
	            	<td><?php echo $no++;?></td>
	                <td><?php echo $r->detail_nama;?></td>
	                <td><?php echo $r->detail_alamat;?></td>                
	                <td><?php echo $r->detail_tglakad;?></td>
	                <td><?php echo $r->detail_tgllahir;?></td>
	                <td align="center"><?php echo $r->detail_usia;?> Thn</td>
	                <td align="center"><?php echo $r->detail_periode_ptg;?></td>
	                <td><?php echo myNum($r->detail_uang_ptg);?></td>
	                <td><?php echo $r->detail_tarif_premi;?></td>
	                <?php if($this->bav_type == 'agunan'){?>
	                <td><?php echo $r->detail_obj_ptg;?></td>
	                <?php }?>
	                <td><?php echo myNum($premi);?></td>
	            </tr>   
	    <?php } 
		}
		?>
	</table>
</body>
</html>
